<!DOCTYPE html>
<html >
<head>
	<meta charset="UTF-8">
	<title>Document</title>
  <script type="text/javascript" src="<?php echo base_url();?>/public/js/jquery.min.js"></script>
  <link href="<?php echo base_url();?>/public/css/bootstrap.min.css" rel="stylesheet">
  <link href="<?php echo base_url();?>/public/css/bootstrap-theme.min.css" rel="stylesheet">
  <link href="<?php echo base_url();?>/public/css/style.css" rel="stylesheet">

  </head>
<body>
<?php $this->load->view("admin/nav"); ?>
<div class="container">
  <h1>文章<small>标题</small><a href="<?php echo site_url('admin/article/add') ?>" class="btn btn-primary pull-right">添加</a></h1>

     <table id="main" class="table table-bordered">
   	   <tr>
   	   	 <td id="bt"><b>标题</b></td>
         <td id="cj"><b>创建时间</b></td>
         <td id="fw"><b>访问人数</b></td>
         <td ><b>是否推荐</b></td>
   	     <td id="cz"><b>操作</b></td>
      </tr>
    <?php 
       if(empty($articles)){
    ?>
      <tr>
      <td class="empty" colspan="9">没有数据</td>
      </tr>
 <?php 
       }
    ?>
   	   <?php
          foreach ($articles as $ba) {
       ?>
   	    <tr>
     	   	<td width="500px"><a href="../blog/title-line.php?id=<?php echo $ba->id ?>"><?php echo $ba->title ?></a></td>
          <td width="200px"><?php  echo date("Y-m-d H:i:s", $ba->create_time )?></td>
          <td width="160px"><?php  echo $ba->view ?></td>
          <td width="160px"><?php  echo $ba->recommend==1?'<span class="label label-success">已推荐</span>':"" ?></td>

          <td width="300px">
         <?php
          if ($ba->recommend==1){
          ?>
          <a class="btn btn-success btn-xs recommend" href="<?php echo site_url("admin/article/recommend/".$ba->id)?>">取消推荐</a> 

           
            <?php
               }else{
              ?>
         <a  class="btn btn-info btn-xs recommend" href="<?php echo site_url("admin/article/recommend/".$ba->id)?>">推荐</a>
        
            <?php 
            }
            ?>
           
         <a class="btn btn-warning btn-xs edit" href="<?php echo site_url("admin/article/edit/".$ba->id)?>">修改</a>
          <a class="btn btn-danger btn-xs del" class="del" href="<?php echo site_url("admin/article/delete/".$ba->id) ?>">删除</a>
          </td>
         </tr>
   	 <?php
      }
      ?>
     </table>
        <?php echo $this->pagination->create_links(); ?>
   </div>
   <div class="modal fade" id="myModal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">Modal title</h4>
      </div>
      <div class="modal-body">
        <p>One fine body&hellip;</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>
   <script type="text/javascript">
      $(function(){
        $(".recommend").click(function(){
           var href= $(this).attr('href');
           $.get(href,function(){
             location.reload();
            });
           return false;
        });
   
  
        $(".del").click(function(){
          if(confirm('确定删除？')){
           var href= $(this).attr('href');
           $.get(href,function(){
             location.reload();
            });
       }else{
          return false;
       }
         
        });
 
    
        $(".edit").click(function(){
          $('#myModal').modal('show');
           return false;
        });
           });
   </script>
 </body>
</html>